package com.neuedu.corejava.ch10.homework;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import com.neuedu.corejava.ch10.Computer;
import com.neuedu.corejava.ch4.practise.Foreach;


public class Test2 {

	public static void main(String[] args) {
		List list = new ArrayList();
		Student student1=new Student("AA",160,20);
		Student student2=new Student("BB",160,21);
		Student student3=new Student("CC",160,22);
		
		
		list.add(student1);
		list.add(student2);
		list.add(student3);
		System.out.println("size="+list.size());
		
		
		//使用迭代遍历查询
		Iterator iterator=list.iterator();
		while (iterator.hasNext()) {
			Student stu=(Student) iterator.next();
			System.out.println(stu);
		}

		
		//foreach遍历
		for (Object stu1 : list) {
			System.out.println(stu1.toString());
		}
	
		
		
		
		
		//使用for循环迭代集合
		for(int i=0;i<list.size();i++) {
			Student stu=(Student)list.get(i);
			    System.out.println(stu);
		}

	}

}
